package com.cskaoyan.javase.network._2tcp._v4;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 * 客户端
 * 序列化一个对象,传给服务端
 *
 * @since 16:24
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 11111);
        Student s = new Student(18, "张三");
        // 需要对象流,并且需要将对象数据写到服务端
        OutputStream out = socket.getOutputStream();
        // 字节输出流 --> 对象输出流
        ObjectOutputStream objOut = new ObjectOutputStream(out);
        objOut.writeObject(s);

        // close
        socket.close();
    }
}
